<?php
require_once("conf/db_connection.php");

$filter_date = $_GET['filter_date'];

if($filter_date=="" || $filter_date==null)
{
$query_awarded="SELECT * FROM trip_detail where status='awarded'";
$query_pullout="SELECT * FROM trip_detail where status='pullout'";
$query_pickup="SELECT * FROM trip_detail where status='pickup'";
$query_inyard="SELECT * FROM trip_detail where status='inyard'";
}
else
{
$query_awarded="SELECT * FROM trip_detail where status='awarded' AND receive_date_time LIKE '".$filter_date."%'";
$query_pullout="SELECT * FROM trip_detail where status='pullout' AND receive_date_time LIKE '".$filter_date."%'";
$query_pickup="SELECT * FROM trip_detail where status='pickup' AND receive_date_time LIKE '".$filter_date."%'";
$query_inyard="SELECT * FROM trip_detail where status='inyard' AND receive_date_time LIKE '".$filter_date."%'";
}


$result_awarded=mysql_query($query_awarded);
$result_pullout=mysql_query($query_pullout);
$result_pickup=mysql_query($query_pickup);
$result_inyard=mysql_query($query_inyard);
?>
<html>
<head>
<script type="text/javascript" src="lib/js/jquery-1.7.1.js"></script>
<link rel="stylesheet" href="lib/js/jqueryui/css/blitzer/jquery-ui-1.8.17.custom.css">
<!--<link rel="stylesheet" href="lib/js/jqueryui/css/ui-lightness/jquery-ui-1.8.17.custom.css">-->
<script type="text/javascript" src="lib/js/jqueryui/js/jquery-ui-1.8.17.custom.min.js"></script>
<style type = "text/css">
#hor-minimalist-b {
	background-color: #FFFFFF;
    border-collapse: collapse;
    font-family: Georgia;
    font-size: 12px;
    margin: 10px;
    text-align: center;
    width: 900px;
}
#hor-minimalist-b th {
    border-bottom: 2px solid #5F0C0C ;
    color: #5F0C0C;
    font-size: 12px;
    font-weight: bold;
    padding: 10px 8px;
}
#hor-minimalist-b td {
    border-bottom: 1px solid #888888;
    color: #000000;
    padding: 6px 8px;
}
#hor-minimalist-b tbody tr:hover td {
    //color: #0000CC;
	background-color:#BCC5C6;
}
</style>
<script>
$(document).ready(function ()
{


		$( "#datepicker" ).datepicker();
		$( "#datepicker" ).datepicker( "option", "dateFormat", 'yy-mm-dd' );
		
		if($("#hfDate").val())
		{
		//$( "#datepicker" ).datepicker( "option", "defaultDate", $("#hfDate").val() );
		$( "#datepicker" ).val($("#hfDate").val());
		}

});
function changeDate(passed_date)
{
document.location.href = "trip_detail_list.php?filter_date="+passed_date;
}

function refreshList()
{
	
	var hfdate = document.getElementById('hfDate').value;
	document.location.href = 'trip_detail_list.php?filter_date='+hfdate;
}
</script>
</head>
<body>
<table border='1' width='900' style='background-color:white;margin-left:auto;margin-right:auto;background-color:#5F0C0C;color:white;font-family:Georgia;font-size:12px'>
<th>TRIP DETAIL LIST</th>
</table>

<br />
<!--<div style='position:relative;left:55px;width:900px'><span style='font-family:Georgia;font-size:12px;color:white;font-weight:bold'>Date:&nbsp;</span><input type='text' id='datepicker' name='datepicker' onChange=changeDate(this.value);></div>
<input type='hidden' id='hfDate' name='hfDate' value='<?php echo $filter_date?>' />-->
<table width='900' style='background-color:black;margin-left:auto;margin-right:auto;color:white;font-family:Georgia;font-size:12px'>
<tr>
	<td align = 'left'>
		<span style='font-family:Georgia;font-size:12px;color:white;font-weight:bold'>Date:&nbsp;</span><input type='text' id='datepicker' name='datepicker' onChange=changeDate(this.value);>
		<input type='hidden' id='hfDate' name='hfDate' value='<?php echo $filter_date?>' />
	</td>
</tr>
</table>

<!--AWARDED-->
<br />
<table border='1' width='900' style='background-color:white;margin-left:auto;margin-right:auto;background-color:gray;color:white;font-family:Georgia;font-size:12px'>
<th>AWARDED</th>
</table>
<table id='hor-minimalist-b' border='0' width='900' style='margin-left:auto;margin-right:auto'>
<thead>
<tr>
	<th>Booking Number</th>
	<th>TAS Number</th>
	<th>Customer</th>
	<th>Plate</th>
	<th>Delivery Date</th>
	<th>Received Date Time</th>
	<th>Status</th>
	<th>Address</th>
</tr>
</thead>
<?php
if(mysql_num_rows($result_awarded)==0)
{
?>
<tbody>
<tr>
	<td style="text-align:center; font-family:Georgia; font-size:12px; font-weight:bold" colspan='8'>NO DATA</td>
</tr>
</tbody>
<?php
}
else
{
while($row_awarded = mysql_fetch_array($result_awarded))
{
$query_trip = "SELECT * FROM truck WHERE id='".$row_truck['truck_id']."'";
				$result_trip = mysql_query($query_trip) or die("ERROR");
				$row_trip = mysql_fetch_array($result_trip);
				
if($row_awarded['is_available']=="1")
{
	$img_avail = "<img src='image/green_btn.png' style='cursor:pointer' title='This vehicle is available.'>";
	//onClick=checkAvailable('".$row_truck['id']."','".$row_truck['is_available']."')
}
else if($row_awarded['is_available']=="0")
{
	$img_avail = "<img src='image/red_btn.png' style='cursor:pointer' title='This vehicle is unavailable.'>";
	//onClick=checkAvailable('".$row_truck['id']."','".$row_truck['is_available']."')
}
else if($row_awarded['is_available']=="2")
{
	$img_avail = "<img src='image/orange_btn.png' style='cursor:pointer' title='This vehicle is in use.'>";
	//onClick=checkAvailable('".$row_truck['id']."','".$row_truck['is_available']."')
}
?>
<tbody>
<tr>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_awarded["booking_number"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_awarded["tas_number"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_awarded["customer"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_awarded["plate"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_awarded["positioning_date"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_awarded["receive_date_time"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo strtoupper($row_awarded["status"]) ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_awarded["pick_address"] ?>&nbsp;</td>
</tr>
</tbody>
<?php
}
}
?>
</table>

<!--PULLOUT-->
<br />
<table border='1' width='900' style='background-color:white;margin-left:auto;margin-right:auto;background-color:gray;color:white;font-family:Georgia;font-size:12px'>
<th>PULLOUT</th>
</table>
<table id='hor-minimalist-b' border='0' width='900' style='margin-left:auto;margin-right:auto'>
<thead>
<tr>
	<th>Booking Number</th>
	<th>TAS Number</th>
	<th>Customer</th>
	<th>Plate</th>
	<th>Delivery Date</th>
	<th>Received Date Time</th>
	<th>Status</th>
	<th>Address</th>
</tr>
</thead>
<?php
if(mysql_num_rows($result_pullout)==0)
{
?>
<tbody>
<tr>
	<td style="text-align:center; font-family:Georgia; font-size:12px; font-weight:bold" colspan='8'>NO DATA</td>
</tr>
</tbody>
<?php
}
else
{
while($row_pullout = mysql_fetch_array($result_pullout))
{
$query_trip = "SELECT * FROM truck WHERE id='".$row_pullout['truck_id']."'";
				$result_trip = mysql_query($query_trip) or die("ERROR");
				$row_trip = mysql_fetch_array($result_trip);
				
if($row_pullout['is_available']=="1")
{
	$img_avail = "<img src='image/green_btn.png' style='cursor:pointer' title='This vehicle is available.'>";
	//onClick=checkAvailable('".$row_truck['id']."','".$row_truck['is_available']."')
}
else if($row_pullout['is_available']=="0")
{
	$img_avail = "<img src='image/red_btn.png' style='cursor:pointer' title='This vehicle is unavailable.'>";
	//onClick=checkAvailable('".$row_truck['id']."','".$row_truck['is_available']."')
}
else if($row_pullout['is_available']=="2")
{
	$img_avail = "<img src='image/orange_btn.png' style='cursor:pointer' title='This vehicle is in use.'>";
	//onClick=checkAvailable('".$row_truck['id']."','".$row_truck['is_available']."')
}
?>
<tbody>
<tr>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_pullout["booking_number"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_pullout["tas_number"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_pullout["customer"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_pullout["plate"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_pullout["positioning_date"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_pullout["receive_date_time"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo strtoupper($row_pullout["status"]) ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_pullout["pick_address"] ?>&nbsp;</td>
</tr>
</tbody>
<?php
}
}
?>
</table>


<!--PICKUP-->
<br />
<table border='1' width='900' style='background-color:white;margin-left:auto;margin-right:auto;background-color:gray;color:white;font-family:Georgia;font-size:12px'>
<th>PICKUP</th>
</table>
<table id='hor-minimalist-b' border='0' width='900' style='margin-left:auto;margin-right:auto'>
<thead>
<tr>
	<th>Booking Number</th>
	<th>TAS Number</th>
	<th>Customer</th>
	<th>Plate</th>
	<th>Delivery Date</th>
	<th>Received Date Time</th>
	<th>Status</th>
	<th>Address</th>
</tr>
</thead>
<?php
if(mysql_num_rows($result_pickup)==0)
{
?>
<tbody>
<tr>
	<td style="text-align:center; font-family:Georgia; font-size:12px; font-weight:bold" colspan='8'>NO DATA</td>
</tr>
</tbody>
<?php
}
else
{
while($row_pickup = mysql_fetch_array($result_pickup))
{
$query_trip = "SELECT * FROM truck WHERE id='".$row_pickup['truck_id']."'";
				$result_trip = mysql_query($query_trip) or die("ERROR");
				$row_trip = mysql_fetch_array($result_trip);
				
if($row_pickup['is_available']=="1")
{
	$img_avail = "<img src='image/green_btn.png' style='cursor:pointer' title='This vehicle is available.'>";
	//onClick=checkAvailable('".$row_truck['id']."','".$row_truck['is_available']."')
}
else if($row_pickup['is_available']=="0")
{
	$img_avail = "<img src='image/red_btn.png' style='cursor:pointer' title='This vehicle is unavailable.'>";
	//onClick=checkAvailable('".$row_truck['id']."','".$row_truck['is_available']."')
}
else if($row_pickup['is_available']=="2")
{
	$img_avail = "<img src='image/orange_btn.png' style='cursor:pointer' title='This vehicle is in use.'>";
	//onClick=checkAvailable('".$row_truck['id']."','".$row_truck['is_available']."')
}
?>
<tbody>
<tr>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_pickup["booking_number"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_pickup["tas_number"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_pickup["customer"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_pickup["plate"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_pickup["positioning_date"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_pickup["receive_date_time"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo strtoupper($row_pickup["status"]) ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_pickup["pick_address"] ?>&nbsp;</td>
</tr>
</tbody>
<?php
}
}
?>
</table>


<!--INYARD-->
<br />
<table border='1' width='900' style='background-color:white;margin-left:auto;margin-right:auto;background-color:gray;color:white;font-family:Georgia;font-size:12px'>
<th>INYARD</th>
</table>
<table id='hor-minimalist-b' border='0' width='900' style='margin-left:auto;margin-right:auto'>
<thead>
<tr>
	<th>Booking Number</th>
	<th>TAS Number</th>
	<th>Customer</th>
	<th>Plate</th>
	<th>Delivery Date</th>
	<th>Received Date Time</th>
	<th>Status</th>
	<th>Address</th>
</tr>
</thead>
<?php
if(mysql_num_rows($result_inyard)==0)
{
?>
<tbody>
<tr>
	<td style="text-align:center; font-family:Georgia; font-size:12px; font-weight:bold" colspan='8'>NO DATA</td>
</tr>
</tbody>
<?php
}
else
{
while($row_inyard = mysql_fetch_array($result_inyard))
{
$query_trip = "SELECT * FROM truck WHERE id='".$row_inyard['truck_id']."'";
				$result_trip = mysql_query($query_trip) or die("ERROR");
				$row_trip = mysql_fetch_array($result_trip);
				
if($row_inyard['is_available']=="1")
{
	$img_avail = "<img src='image/green_btn.png' style='cursor:pointer' title='This vehicle is available.'>";
	//onClick=checkAvailable('".$row_truck['id']."','".$row_truck['is_available']."')
}
else if($row_inyard['is_available']=="0")
{
	$img_avail = "<img src='image/red_btn.png' style='cursor:pointer' title='This vehicle is unavailable.'>";
	//onClick=checkAvailable('".$row_truck['id']."','".$row_truck['is_available']."')
}
else if($row_inyard['is_available']=="2")
{
	$img_avail = "<img src='image/orange_btn.png' style='cursor:pointer' title='This vehicle is in use.'>";
	//onClick=checkAvailable('".$row_truck['id']."','".$row_truck['is_available']."')
}
?>
<tbody>
<tr>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_inyard["booking_number"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_inyard["tas_number"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_inyard["customer"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_inyard["plate"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_inyard["positioning_date"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_inyard["receive_date_time"] ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo strtoupper($row_inyard["status"]) ?>&nbsp;</td>
	<td style="text-align:center; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_inyard["pick_address"] ?>&nbsp;</td>
</tr>
</tbody>
<?php
}
}
?>
</table>		
</body>
</html>

